package org.osami.commons.smarthome.programnotifier;

import java.util.Date;
import java.util.Calendar;
import java.util.Scanner;
import java.util.Vector;
import javax.xml.parsers.*;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.Attributes;
import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.text.DateFormat;

public class ProgramInfo implements Comparable {
	private String channel = "";
	private String name = "";
	private String serviceRef = "";
	private String deviceId = "";
	private Date startTime = new Date();
	private Date endTime = new Date();
	private int duration;
	private int id;
	private static SimpleDateFormat	df = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
	private Vector alerts = new Vector();
	
	//@SuppressWarnings("deprecation")
	public ProgramInfo() {
		
		//try {
			//System.out.print(string);
			
		//} catch (Exception ex) {
			//System.out.println("Error: " + ex.getMessage());
		//}
		
	}
	
	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setChannel(String channel) {
		this.channel = channel;
	}

	public String getChannel() {
		return channel;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public Date getEndTime() {
		return endTime;
	}
	
	public void setDuration(int duration) {
		this.duration = duration;
	}

	public int getDuration() {
		return duration;
	}
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	public String getServiceReference() {
		return serviceRef;
	}

	public void setServiceReference(String serviceRef) {
		this.serviceRef = serviceRef;
	}
	
	public void setDeviceId(String deviceId) {
		this.deviceId = deviceId;
	}

	public String getDeviceId() {
		return deviceId;
	}
	
	public int compareTo(Object another) throws ClassCastException {
		if (!(another instanceof ProgramInfo))
			throw new ClassCastException("Ei näin, vauhtia hakemaan");
		
		return getStartTime().compareTo(((ProgramInfo)another).getStartTime());
	}
	
	public void print() {
		System.out.println("deviceId = " + this.deviceId);
		System.out.println("channel = " + this.channel);
		System.out.println("name = " + this.name);
		System.out.println("startTime = " + df.format(this.startTime));
		System.out.println("endTime = " + df.format(this.endTime));
		System.out.println("id = " + this.id);
		System.out.println("serviceRef = " + this.serviceRef);
	}
}
